package com.web.security.provider;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.security.providers.encoding.PasswordEncoder;

import com.web.security.service.SecurityService;

public class CustomPasswordEncoder implements PasswordEncoder{

	@Autowired
	private SecurityService securityPasswordService;
	
	@Override
	public String encodePassword(String rawPass, Object arg1)
			throws DataAccessException {
		return securityPasswordService.encodePassword(rawPass);
	}

	@Override
	public boolean isPasswordValid(String encPass, String rawPass, Object arg2)
			throws DataAccessException {
		return encPass.equals(securityPasswordService.encodePassword(rawPass));
	}

}
